<template>
  <div class="exciter-introduction">
    <!-- 页面头部 -->
    <div class="page-header">
      <el-page-header @back="goBack" content="励磁机原理介绍">
        <template #title>
          <span class="header-title">整流发电机虚拟训练软件</span>
        </template>
        <template #extra>
          <div class="header-actions">
            <el-button type="primary" :icon="Printer" @click="handlePrint">打印</el-button>
            <el-button :icon="Download" @click="handleDownload">下载PDF</el-button>
<!--            <el-button :icon="Star" @click="handleFavorite">收藏</el-button>-->
          </div>
        </template>
      </el-page-header>
    </div>

    <!-- 内容区域 -->
    <div class="markdown-content">
      <!-- 标题区域 -->
      <h1 class="content-title">励磁机原理与结构介绍</h1>

      <!-- 概述部分 -->
      <section class="content-section">
        <h2>1. 励磁机概述</h2>
        <p>励磁机是发电机组的重要组成部分，主要负责为发电机转子提供直流励磁电流，通过调节励磁电流的大小来控制发电机的输出电压和功率因数。</p>

        <p>在十二相整流发电机系统中，励磁机的作用尤为关键，它确保发电机在不同负载条件下都能保持稳定的输出电压，为船舶电力系统提供可靠的电能。</p>

        <!-- 励磁机在发电机组中的位置示意图 -->
        <div class="image-placeholder">
          <p class="placeholder-text">[图：励磁机在发电机组中的安装位置示意图]</p>
          <div class="placeholder-box">
            <span>励磁机安装位置示意图</span>
          </div>
        </div>
      </section>

      <!-- 结构组成 -->
      <section class="content-section">
        <h2>2. 励磁机结构组成</h2>

        <h3>2.1 主要组成部分</h3>
        <p>励磁机主要由以下部件组成：</p>

        <el-row :gutter="20">
          <el-col :span="12">
            <div class="component-list">
              <div class="component-item">
                <h4>励磁机定子</h4>
                <ul>
                  <li>定子铁芯：由硅钢片叠压而成</li>
                  <li>定子绕组：产生励磁磁场</li>
                  <li>机座：支撑和固定定子</li>
                </ul>
              </div>

              <div class="component-item">
                <h4>励磁机转子</h4>
                <ul>
                  <li>转子铁芯：安装在转轴上</li>
                  <li>转子绕组：切割磁场产生感应电动势</li>
                  <li>滑环：引出转子电流</li>
                </ul>
              </div>
            </div>
          </el-col>

          <el-col :span="12">
            <!-- 励磁机结构示意图 -->
            <div class="image-placeholder">
              <p class="placeholder-text">[图：励磁机内部结构示意图]</p>
              <div class="placeholder-box">
                <span>励磁机结构分解图</span>
              </div>
            </div>
          </el-col>
        </el-row>

        <h3>2.2 辅助系统</h3>
        <p>励磁机还包括以下辅助系统：</p>

        <el-collapse v-model="activeCollapse">
          <el-collapse-item title="冷却系统" name="cooling">
            <p>确保励磁机在运行过程中保持适宜的工作温度，防止过热损坏。</p>
            <ul>
              <li>风冷系统：通过风扇强制通风</li>
              <li>冷却风道：优化气流路径</li>
              <li>温度监测：实时监控励磁机温度</li>
            </ul>
          </el-collapse-item>

          <el-collapse-item title="励磁调节系统" name="regulation">
            <p>与自动电压调节器(AVR)配合，精确控制励磁电流。</p>
            <ul>
              <li>励磁控制器：接收AVR指令</li>
              <li>功率放大单元：放大控制信号</li>
              <li>反馈检测：监测励磁电流和电压</li>
            </ul>
          </el-collapse-item>

          <el-collapse-item title="保护系统" name="protection">
            <p>确保励磁机在异常情况下安全运行。</p>
            <ul>
              <li>过流保护：防止励磁电流过大</li>
              <li>过压保护：防止励磁电压过高</li>
              <li>失磁保护：检测励磁故障</li>
            </ul>
          </el-collapse-item>
        </el-collapse>
      </section>

      <!-- 工作原理 -->
      <section class="content-section">
        <h2>3. 励磁机工作原理</h2>

        <h3>3.1 基本工作原理</h3>
        <p>励磁机基于电磁感应原理工作，通过原动机带动旋转，在励磁绕组中通入直流电流产生磁场，该磁场切割电枢绕组产生交流电动势，经整流后供给发电机转子励磁。</p>

        <!-- 励磁机工作原理图 -->
        <div class="image-placeholder">
          <p class="placeholder-text">[图：励磁机工作原理框图]</p>
          <div class="placeholder-box large">
            <span>励磁机工作原理示意图</span>
            <p>展示励磁电流产生、调节和反馈的全过程</p>
          </div>
        </div>

        <h3>3.2 工作流程</h3>
        <ol>
          <li>原动机带动励磁机转子旋转</li>
          <li>励磁绕组通入直流电产生磁场</li>
          <li>旋转磁场切割定子电枢绕组</li>
          <li>电枢绕组中产生感应交流电动势</li>
          <li>交流电经旋转整流器转换为直流电</li>
          <li>直流电供给发电机转子建立磁场</li>
          <li>AVR根据发电机输出电压调节励磁电流</li>
        </ol>

        <!-- 励磁系统拓扑图 -->
        <div class="image-placeholder">
          <p class="placeholder-text">[图：励磁装置拓扑图]</p>
          <div class="placeholder-box">
            [](@replace=1)
          </div>
        </div>
      </section>

      <!-- 技术参数 -->
      <section class="content-section">
        <h2>4. 主要技术参数</h2>

        <el-table :data="technicalParams" stripe style="width: 100%">
          <el-table-column prop="parameter" label="参数名称" width="180"></el-table-column>
          <el-table-column prop="value" label="参数值" width="120"></el-table-column>
          <el-table-column prop="unit" label="单位" width="80"></el-table-column>
          <el-table-column prop="description" label="说明"></el-table-column>
        </el-table>

        <h3>4.1 性能特点</h3>
        <p>十二相整流发电机系统中的励磁机具有以下性能特点：</p>

        <el-row :gutter="16">
          <el-col :span="8">
            <el-card shadow="hover" class="feature-card">
              <template #header>
                <div class="feature-header">
                  <el-icon><TrendCharts /></el-icon>
                  <span>高响应速度</span>
                </div>
              </template>
              <div class="feature-content">
                <p>励磁系统响应时间小于0.1秒，确保电压快速稳定</p>
              </div>
            </el-card>
          </el-col>

          <el-col :span="8">
            <el-card shadow="hover" class="feature-card">
              <template #header>
                <div class="feature-header">
                  <el-icon><Setting /></el-icon>
                  <span>精确调节</span>
                </div>
              </template>
              <div class="feature-content">
                <p>励磁电流调节精度达到±1%，保证输出电压稳定</p>
              </div>
            </el-card>
          </el-col>

          <el-col :span="8">
            <el-card shadow="hover" class="feature-card">
              <template #header>
                <div class="feature-header">
                  <el-icon><Lock /></el-icon>
                  <span>高可靠性</span>
                </div>
              </template>
              <div class="feature-content">
                <p>多重保护机制，确保励磁系统安全可靠运行</p>
              </div>
            </el-card>
          </el-col>
        </el-row>
      </section>

      <!-- 维护与故障处理 -->
      <section class="content-section">
        <h2>5. 维护与故障处理</h2>

        <h3>5.1 日常维护要点</h3>
        <el-timeline>
          <el-timeline-item timestamp="每日检查" placement="top">
            <el-card>
              <h4>日常检查项目</h4>
              <ul>
                <li>检查励磁机运行声音是否正常</li>
                <li>监测励磁机轴承温度</li>
                <li>检查碳刷磨损情况（如适用）</li>
                <li>观察励磁电流和电压指示</li>
              </ul>
            </el-card>
          </el-timeline-item>

          <el-timeline-item timestamp="每周检查" placement="top">
            <el-card>
              <h4>周检项目</h4>
              <ul>
                <li>清洁励磁机外部和通风孔</li>
                <li>检查接线端子紧固情况</li>
                <li>测试保护装置功能</li>
                <li>记录运行参数变化趋势</li>
              </ul>
            </el-card>
          </el-timeline-item>

          <el-timeline-item timestamp="每月检查" placement="top">
            <el-card>
              <h4>月检项目</h4>
              <ul>
                <li>测量绝缘电阻</li>
                <li>检查冷却系统工作状态</li>
                <li>校准测量仪表</li>
                <li>全面清洁内部灰尘</li>
              </ul>
            </el-card>
          </el-timeline-item>
        </el-timeline>

        <h3>5.2 常见故障及处理</h3>

        <el-collapse v-model="activeFaults" accordion>
          <el-collapse-item title="励磁电流异常" name="current">
            <div class="fault-content">
              <h4>故障现象：</h4>
              <ul>
                <li>励磁电流指示不稳定</li>
                <li>发电机输出电压波动</li>
                <li>AVR调节异常报警</li>
              </ul>

              <h4>可能原因：</h4>
              <ul>
                <li>励磁绕组匝间短路</li>
                <li>旋转整流器故障</li>
                <li>AVR控制板故障</li>
                <li>接线端子松动</li>
              </ul>

              <h4>处理方法：</h4>
              <ol>
                <li>检查励磁绕组绝缘电阻</li>
                <li>测试旋转整流器二极管</li>
                <li>检查AVR输出信号</li>
                <li>紧固所有接线端子</li>
              </ol>
            </div>
          </el-collapse-item>

          <el-collapse-item title="励磁机过热" name="overheat">
            <div class="fault-content">
              <h4>故障现象：</h4>
              <ul>
                <li>励磁机表面温度过高</li>
                <li>冷却风扇异常噪声</li>
                <li>绝缘电阻下降</li>
              </ul>

              <h4>可能原因：</h4>
              <ul>
                <li>冷却风道堵塞</li>
                <li>轴承润滑不良</li>
                <li>过载运行</li>
                <li>环境温度过高</li>
              </ul>

              <h4>处理方法：</h4>
              <ol>
                <li>清理冷却风道</li>
                <li>检查轴承润滑情况</li>
                <li>降低负载至额定值</li>
                <li>改善通风条件</li>
              </ol>
            </div>
          </el-collapse-item>

          <el-collapse-item title="失磁故障" name="loss">
            <div class="fault-content">
              <h4>故障现象：</h4>
              <ul>
                <li>发电机输出电压急剧下降</li>
                <li>励磁电流为零或接近零</li>
                <li>保护装置动作</li>
              </ul>

              <!-- 失磁故障诊断流程图 -->
              <div class="image-placeholder">
                <p class="placeholder-text">[图：失磁故障诊断流程图]</p>
                <div class="placeholder-box">
                  <span>失磁故障诊断流程</span>
                </div>
              </div>
            </div>
          </el-collapse-item>
        </el-collapse>
      </section>

      <!-- 相关知识链接 -->
      <section class="content-section">
        <h2>6. 相关知识链接</h2>

        <div class="knowledge-links">
          <el-card
              v-for="link in relatedLinks"
              :key="link.title"
              class="link-card"
              @click="navigateTo(link.path)"
          >
            <template #header>
              <div class="card-header">
                <el-icon><Connection /></el-icon>
                <span>{{ link.title }}</span>
              </div>
            </template>
            <div class="card-content">
              <p>{{ link.description }}</p>
              <div class="card-actions">
                <el-tag :type="link.type" size="small">{{ link.category }}</el-tag>
              </div>
            </div>
          </el-card>
        </div>
      </section>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue';
import { useRouter } from 'vue-router';
import { Printer, Download, Star, Connection, TrendCharts, Setting, Lock } from '@element-plus/icons-vue';

const router = useRouter();
const activeCollapse = ref(['cooling']);
const activeFaults = ref(['current']);

// 技术参数数据
const technicalParams = ref([
  {
    parameter: '额定励磁电压',
    value: '110',
    unit: 'V',
    description: '励磁机额定工作电压'
  },
  {
    parameter: '额定励磁电流',
    value: '10',
    unit: 'A',
    description: '励磁机额定工作电流'
  },
  {
    parameter: '最大励磁电压',
    value: '150',
    unit: 'V',
    description: '励磁机最大允许电压'
  },
  {
    parameter: '响应时间',
    value: '0.1',
    unit: 's',
    description: '励磁系统响应时间'
  },
  {
    parameter: '绝缘等级',
    value: 'F',
    unit: '',
    description: '绕组绝缘耐热等级'
  },
  {
    parameter: '冷却方式',
    value: 'IC01',
    unit: '',
    description: '自冷式通风冷却'
  },
  {
    parameter: '防护等级',
    value: 'IP23',
    unit: '',
    description: '防滴防尘等级'
  },
  {
    parameter: '工作温度',
    value: '-20~40',
    unit: '℃',
    description: '环境工作温度范围'
  }
]);

// 相关知识链接
const relatedLinks = ref([
  {
    title: '自动电压调节器(AVR)',
    description: '了解AVR如何与励磁机配合调节发电机输出电压',
    path: '/principle/avr',
    category: '控制系统',
    type: 'primary'
  },
  {
    title: '旋转整流器原理',
    description: '学习旋转整流器在励磁系统中的作用和工作原理',
    path: '/principle/rotating-rectifier',
    category: '电力电子',
    type: 'success'
  },
  {
    title: '发电机组操作流程',
    description: '掌握包含励磁机在内的完整发电机组操作规范',
    path: '/principle/control-panel',
    category: '操作规程',
    type: 'warning'
  },
  {
    title: '励磁系统故障诊断',
    description: '学习励磁系统常见故障的诊断方法和处理技巧',
    path: '/principle/excitation-topology',
    category: '故障处理',
    type: 'danger'
  }
]);

const goBack = () => {
  router.back();
};

const handlePrint = () => {
  window.print();
};

const handleDownload = () => {
  // 实现PDF下载功能
  console.log('下载PDF');
};

const handleFavorite = () => {
  // 实现收藏功能
  console.log('收藏励磁机原理');
};

const navigateTo = (path) => {
  router.push(path);
};
</script>

<style scoped>
.exciter-introduction {
  padding: 20px;
  background-color: #f5f7fa;
  min-height: 100vh;
}

.page-header {
  margin-bottom: 24px;
  background-color: #fff;
  padding: 16px;
  border-radius: 4px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}

.header-title {
  font-size: 18px;
  font-weight: bold;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.markdown-content {
  background-color: #fff;
  padding: 24px;
  border-radius: 4px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}

.content-title {
  font-size: 28px;
  color: #303133;
  text-align: center;
  margin-bottom: 32px;
  padding-bottom: 16px;
  border-bottom: 2px solid #409eff;
}

.content-section {
  margin-bottom: 40px;
}

.content-section h2 {
  font-size: 22px;
  color: #303133;
  margin-bottom: 16px;
  padding-left: 8px;
  border-left: 4px solid #409eff;
}

.content-section h3 {
  font-size: 18px;
  color: #606266;
  margin: 16px 0 12px 0;
}

.content-section h4 {
  font-size: 16px;
  color: #909399;
  margin: 12px 0 8px 0;
}

.content-section p {
  line-height: 1.6;
  color: #606266;
  margin-bottom: 16px;
}

.content-section ul, .content-section ol {
  padding-left: 24px;
  margin-bottom: 16px;
}

.content-section li {
  line-height: 1.6;
  color: #606266;
  margin-bottom: 8px;
}

/* 图片占位符样式 */
.image-placeholder {
  margin: 20px 0;
  text-align: center;
}

.placeholder-text {
  font-style: italic;
  color: #909399;
  margin-bottom: 10px;
}

.placeholder-box {
  border: 2px dashed #dcdfe6;
  border-radius: 4px;
  padding: 40px 20px;
  background-color: #fafafa;
  color: #909399;
}

.placeholder-box.large {
  min-height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.placeholder-box img {
  max-width: 100%;
  height: auto;
}

/* 组件列表样式 */
.component-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.component-item {
  background-color: #f8f9fa;
  padding: 16px;
  border-radius: 4px;
  border-left: 4px solid #409eff;
}

.component-item h4 {
  margin-top: 0;
  color: #303133;
}

/* 特性卡片样式 */
.feature-card {
  height: 100%;
}

.feature-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: bold;
}

.feature-content {
  min-height: 60px;
}

/* 故障内容样式 */
.fault-content h4 {
  color: #606266;
  margin: 16px 0 8px 0;
}

.fault-content ul, .fault-content ol {
  margin-left: 20px;
}

/* 知识链接样式 */
.knowledge-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.link-card {
  cursor: pointer;
  transition: transform 0.3s, box-shadow 0.3s;
  height: 100%;
}

.link-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: bold;
}

.card-content {
  min-height: 80px;
}

.card-actions {
  margin-top: 12px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .exciter-introduction {
    padding: 12px;
  }

  .markdown-content {
    padding: 16px;
  }

  .content-title {
    font-size: 24px;
  }

  .content-section h2 {
    font-size: 20px;
  }

  .content-section h3 {
    font-size: 16px;
  }

  .knowledge-links {
    grid-template-columns: 1fr;
  }

  .header-actions {
    flex-direction: column;
    gap: 8px;
  }
}

/* 打印样式 */
@media print {
  .page-header, .header-actions {
    display: none;
  }

  .exciter-introduction {
    padding: 0;
    background-color: #fff;
  }

  .markdown-content {
    padding: 0;
    box-shadow: none;
  }

  .placeholder-box {
    border: 1px solid #ccc;
    background-color: #fff;
  }
}
</style>